package com.itheima.servlet03;

import com.itheima.bean.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;


@WebServlet("/CheckStudent")
public class CheckStudent  extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //创建字符输入流对象关联读取的文件
        BufferedReader br = new BufferedReader(new FileReader("E:\\B.txt"));
        //创建集合对象用于保存student对象
        ArrayList<Student> list = new ArrayList<>();
        //循环读取文件中的数据
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter pw = resp.getWriter();
        String line;
        while ((line=br.readLine())!=null) {
            pw.write(line);
            pw.write("<br>");
        }



    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
